<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <h1> <%= title%> </h1>

  <input type="text" class="phone">
  <input type="password" class="pwd">
  <button class="btn">提交</button>

  <script src="js/axios.js"></script>
  <script>
    const phone = document.querySelector('.phone')
    const pwd = document.querySelector('.pwd')
    const btn = document.querySelector('.btn')
    btn.onclick = function () {
      if (/^1[1-9]{4}/.test(phone.value.trim())) {
        console.log(phone.value)
        axios.post('/api/register', {
          phone: phone.value.trim(),
          pwd: pwd.value.trim()
        })
          .then(res => {
            if (res.data.code === 0) {
              console.log(res, 'res')
              // window.location.href = './list'
            }
          })
      }
    }

  </script>
</body>

</html>